package org.springblade.resource.feign;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.FileUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.resource.builder.oss.OssBuilder;
import org.springblade.resource.entity.Attach;
import org.springblade.resource.entity.Oss;
import org.springblade.resource.service.IAttachService;
import org.springblade.resource.vo.AttachVO;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 附件调用服务
 *
 * @author Chill
 */
@NonDS
@RestController
@AllArgsConstructor
public class AttachClient implements IAttachClient {
	private final IAttachService attachService;

	@Override
	@GetMapping(ATTACH_LIST_GUID)
	public R<List<Attach>> attachListGuid(String guid) {
		LambdaQueryWrapper<Attach> queryWrapper = Wrappers.<Attach>query().lambda();
		queryWrapper.eq(Attach::getBusinessModuleGuid, guid);
		return R.data(attachService.list(queryWrapper));
	}

	@Override
	@GetMapping(ATTACH_LIST_GUID_MODULE)
	public R<Attach> attachListGuidAndModule(@RequestParam("guid") String guid,
											 @RequestParam("module") String module){
		return R.data(attachService.getAttachByGuidAndModule(guid, module));
	}
}
